package cn.edu.zafu.bigdata.zengyadian;

class Cube {
    private double length;
    private double width;
    private double height;

    public Cube(double length, double width, double height) {
        this.length = length;
        this.width = width;
        this.height = height;
    }

    public double getLength() {
        return length;
    }

    public double getWidth() {
        return width;
    }

    public double getHeight() {
        return height;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass()!= obj.getClass()) {
            return false;
        }
        cn.edu.zafu.bigdata.zengyadian.Cube other = (cn.edu.zafu.bigdata.zengyadian.Cube) obj;
        return Double.compare(length, other.length) == 0 &&
                Double.compare(width, other.width) == 0 &&
                Double.compare(height, other.height) == 0;
    }
}

public class CudeTest {
    public static void main(String[] args) {
        cn.edu.zafu.bigdata.zengyadian.Cube cube1 = new cn.edu.zafu.bigdata.zengyadian.Cube(5, 5, 5);
        cn.edu.zafu.bigdata.zengyadian.Cube cube2 = new cn.edu.zafu.bigdata.zengyadian.Cube(5, 5, 5);
        cn.edu.zafu.bigdata.zengyadian.Cube cube3 = new cn.edu.zafu.bigdata.zengyadian.Cube(3, 3, 3);

        System.out.println("cube1 和 cube2 是否相等：" + cube1.equals(cube2));
        System.out.println("cube1 和 cube3 是否相等：" + cube1.equals(cube3));
    }
}